<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="mui/mui.min.css">
    <link rel="stylesheet" href="mui/mui.picker.min.css">
    <link rel="stylesheet" href="mui/mui.showLoading.css">
    <link rel="stylesheet" href="css/instructions.css?20180821">
    <script src="js/flexible.js"></script>
    <title>领取说明</title>
</head>

<body>
    <div id="app" class="app">
        <div class="content">
            <div class="my_message" v-html='message'>
                
            </div>
            <div class="btn" @click="jump">同 意</div>
        </div>
        <div class="footer">
            <div class="left_logo">
                <img src="img/right_logo_h.png?20180821" alt="">
            </div>
        </div>
    </div>
    <script src="mui/mui.min.js"></script>
    <script src="mui/mui.showLoading.js"></script>
    <script src="mui/mui.picker.min.js"></script>
    <script src="mui/province.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/config.js"></script>
</body>
<script>
    var url=appconfig.apiUrl;
    let vm = new Vue({
        el: "#app",
        data: {
            message: false,
            prize: true,
            prizeMessage: true,
            rulesMessage: true,
            isMessage: true,
            theRequest:"",
            message:"",
            id:"",
            param:{

            }
        },
        methods: {
            geUrl: function () {
                var theRequest = {};
                var url = decodeURIComponent(location.search); //获取url中"?"符后的字串
                if (url.indexOf("?") != -1) {
                    var str = url.substr(1);
                    var strs = str.split("&");
                    for (var i = 0; i < strs.length; i++) {
                        theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                    }
                }
                return theRequest;
            },
            jump(val) {
                var param={};
                var info=JSON.parse(localStorage.getItem('info'));
                if(info!==null){
                    this.param.name=info.address.name;
                    this.param.address=info.address.address;
                    this.param.province=info.address.province_name;
                    this.param.city=info.address.city_name;
                    this.param.phone=info.address.phone;
                    this.param.region=info.address.country_name;
                    this.param.zip_code=info.address.codeNum;
                    this.param.id=this.id;
                }
                var self=this;
                axios({
                    method: "POST",
                    url:'/luckdraw/doRecive',
                    data: this.param
                }).then(function (res) {
                    mui.hideLoading();
                    if (res.data.code == "0") {
                        window.location.href = "physicalPrize.html?id=" + self.theRequest.id + "&vip_id=" + self.theRequest.vip_id + "&status=3&t=" + new Date().getTime();
                    }else if(res.data.code=="-1"){
                        mui.alert(res.data.msg," ");
                    }
                }).catch(function (err) {
                    console.log(err);
                    mui.hideLoading();
                    console.log(err);
                    mui.alert("服务器异常", " ");
                })
            },
            getMessage(){
                var pirzeMessage=JSON.parse(localStorage.getItem('pirzeMessage'));
                if(pirzeMessage!==null){
                    var luck_draw_item_info=pirzeMessage.luck_draw_item_info;
                    var luck_draw_prize_info=pirzeMessage.luck_draw_record_info;
                    console.log(luck_draw_item_info);
                    console.log(luck_draw_prize_info);
                }
                this.prize_url= luck_draw_item_info.prize_url;
                this.prize_name=luck_draw_item_info.name;
                this.type=luck_draw_item_info.type;
                this.message=luck_draw_item_info.wxplain;
                this.id=luck_draw_prize_info.id;
            }
        },
        mounted() {
            this.getMessage();
            this.theRequest=this.geUrl();
        }
    })
</script>

</html>